package com.funcourse.demo.api.restful.security;

import com.funcourse.demo.api.ApiSystemConstants;
import com.funcourse.demo.model.User;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class AuthUserHolder {

  @Autowired
  HttpServletRequest httpServletRequest;

  public User getAuthUser() {
    Object attribute = httpServletRequest.getAttribute(ApiSystemConstants.SERVLET_ATTR_AUTH);
    User user = (User) attribute;
    return user;
  }

}
